package yzserver.sx4a.dao.ibatis;

import com.sitech.ibnms.core.BaseIbnmsDao;
import yzserver.sx4a.dao.IUserDao;
import yzserver.sx4a.domain.UserDomain;

import java.util.HashMap;
import java.util.List;

public class UserDaoImpl extends BaseIbnmsDao implements IUserDao {


    @Override
    public UserDomain selUser(String id) {
        return (UserDomain)querySingle("shanxi_selUser",id);
    }

    @Override
    public List<UserDomain> selAllUser(String id) {
        return (List<UserDomain>)query("shanxi_selAllUser", id);
    }

    @Override
    public void addUser(UserDomain user) throws Exception{
        insert("shanxi_addUser",user);
    }

    @Override
    public void addUserPosJobRel(String userid, String positionid, String jobid, String sort) throws Exception {
        HashMap map = new HashMap();
        map.put("userid",userid);
        map.put("positionid",positionid);
        map.put("jobid",jobid);
        map.put("sort",sort);
        insert("shanxi_addUserPosJobRel", map);
    }

    @Override
    public void addUserOrgRel(String userid, String orgid,String main) throws Exception {
        HashMap map = new HashMap();
        map.put("userid",userid);
        map.put("orgid",orgid);
        map.put("main",main);
        insert("shanxi_addUserOrgRel", map);
    }

    @Override
    public void delUserPosJobRel(String userid) throws Exception {
        delete("shanxi_delUserPosJobRel", userid);
    }

    @Override
    public void delUserOrgRel(String userid) throws Exception {
        delete("shanxi_delUserOrgRel", userid);
    }

    @Override
    public List selUserPosJobRel(String userid) {
        return query("shanxi_selUserPosJobRel",userid);
    }

    @Override
    public List selUserOrgRel(String userid) {
        return query("shanxi_selUserOrgRel",userid);
    }

    @Override
    public void editUser(UserDomain user) throws Exception {
        update("shanxi_editUser", user);
    }

    @Override
    public void operationUserPwd(String uid, String pwd) throws Exception {
        HashMap map = new HashMap();
        map.put("uid",uid);
        map.put("pwd",pwd);
        update("shanxi_operationUserPwd", map);
    }

    @Override
    public void operationUser(String uid, String enable) throws Exception {
        HashMap map = new HashMap();
        map.put("uid",uid);
        map.put("enable",enable);
        update("shanxi_operationUser", map);
    }

    @Override
    public void delUser(String uid) throws Exception {
        delete("shanxi_delUser", uid);
    }

}
